'''
Created on Sep 10, 2010

05/11/11 - Luigi is now Wario

@author: yev
'''
from mpi4py import MPI
import optparse
import Wario
import Wario2
import Wario3  
import Mario
import Luigi
import time

start_time = time.time()
start_cpu_time = time.clock()
usage = "usage: PipeDream -p workflow.xml"
parser = optparse.OptionParser(usage)
parser.add_option("-p", "--pipework", dest="pipework", type="str",
                  help=("the xml file describing the workflow")
                  )
opts, args = parser.parse_args()

if opts.pipework is None:
    parser.error("Incorrect arguments. Run again with -h to see help")
    
pipework = opts.pipework

comm = MPI.COMM_WORLD
rank = comm.Get_rank()

if rank == 0:
    Mario.work(pipework)
else:
    Wario3.work(pipework)

end_time = time.time()
end_cpu_time = time.clock()

time_difference_minutes = (end_time - start_time)
time_difference_cpu = end_cpu_time - start_cpu_time

print("Luigi %d exiting after %d seconds, after %d CPU seconds" %(rank, time_difference_minutes, time_difference_cpu))
